package com.zbf.weixinweb;

import com.zbf.weixinwangyeshouqaun.QrCodeUtil2;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * @author: LCG
 * @Date: 2021-10-29 10:20:39
 * @description:
 **/
@RestController
@RequestMapping("/api")
public class WeXinnotifyController {

    @RequestMapping("/ticket")
    public String getWeXinNotify(HttpServletRequest request){

        Map<String, String[]> parameterMap = request.getParameterMap();

        System.out.println("===="+parameterMap);

        return "success";
    }

    @RequestMapping("getQrcode")
    public void toQrcodeForWeb(HttpServletRequest request, HttpServletResponse response) throws IOException {

        byte[] qrCodeByte = QrCodeUtil2.createQRCodeByte("weixin://wxpay/bizpayurl?pr=w37WC1Dzz");
        response.setHeader("Content-Type","image/png");
        response.getOutputStream().write(qrCodeByte);
        response.flushBuffer();

    }

}
